package com.ruoyi.web.controller;


import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.web.domain.dto.PolicyCrawlArticleDto;
import com.ruoyi.web.domain.vo.PolicyCrawlArticleVo;
import com.ruoyi.web.service.PolicyCrawlArticleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Api(tags = "政策法规控制层")
@RequestMapping("/policyCrawlArticle")
public class PolicyCrawlArticleController extends BaseController {

    protected final Logger logger = LoggerFactory.getLogger(PolicyCrawlArticleController.class);
    @Autowired
    private PolicyCrawlArticleService policyCrawlArticleService;

    @ApiOperation(value = "分页查询政策法规列表")
    @GetMapping("/findPolicyCrawlArticlePage")
    public AjaxResult findPolicyCrawlArticlePage(PolicyCrawlArticleDto policyCrawlArticleDto) {
        try {
            startPage();
            List<PolicyCrawlArticleVo> list = policyCrawlArticleService.findPolicyCrawlArticlePage(policyCrawlArticleDto);
            return AjaxResult.success(getDataTable(list));
        } catch (Exception e) {
            logger.error("分页查询政策法规列表异常：===》" + e);
            return AjaxResult.error(e.getMessage());
        }
    }

    @ApiOperation(value = "查询政策法规详情")
    @GetMapping("/getPolicyCrawlArticleDetails")
    public AjaxResult getPolicyCrawlArticleDetails(@RequestParam("baseId") String baseId) {
        try {
            PolicyCrawlArticleVo policyCrawlArticle = policyCrawlArticleService.getPolicyCrawlArticleById(baseId);
            return AjaxResult.success(policyCrawlArticle);
        } catch (Exception e) {
            logger.error("查询政策法规详情异常：===》" + e);
            return AjaxResult.error(e.getMessage());
        }
    }
}